package com.tuyan.aixiang.activity.home.msg;

import android.view.View;

import com.google.android.flexbox.FlexboxLayout;
import com.tuyan.aixiang.R;
import com.tuyan.aixiang.common.AppData;
import com.tuyan.aixiang.common.BaseFragment;
import com.tuyan.aixiang.common.BasePresenter;
import com.tuyan.aixiang.common.Constant;
import com.tuyan.aixiang.component.MsgCategoryItem;

import butterknife.BindView;

public class MsgFragment extends BaseFragment {


    @BindView(R.id.fbl_container)
    FlexboxLayout fblContainer;


    @Override
    protected void initView(View contentView) {

        MsgCategoryItem camera = new MsgCategoryItem(getContext());
        camera.setUp(R.string.category_camera, R.drawable.icon_camera, Constant.NOTICE_LIST + "?type=" + Constant.MODEL_CAMERA + "&subType=" + Constant.SUB_MOTION_DETECT);
        camera.setCount(AppData.globalNoticeCount.getMonitor());

        MsgCategoryItem smoke = new MsgCategoryItem(getContext());
        smoke.setUp(R.string.category_smoke, R.drawable.icon_smoke, Constant.NOTICE_LIST + "?type=" + Constant.MODEL_ALARM + "&subType=" + Constant.SUB_ALARM_TYPE_GAS);
        smoke.setCount(AppData.globalNoticeCount.getGas());

        MsgCategoryItem gas = new MsgCategoryItem(getContext());
        gas.setUp(R.string.category_gas, R.drawable.icon_gas, Constant.NOTICE_LIST + "?type=" + Constant.MODEL_ALARM + "&subType=" + Constant.SUB_ALARM_TYPE_CO);
        gas.setCount(AppData.globalNoticeCount.getFire());

        MsgCategoryItem water = new MsgCategoryItem(getContext());
        water.setUp(R.string.category_water, R.drawable.icon_water, Constant.NOTICE_LIST + "?type=" + Constant.MODEL_ALARM+ "&subType=" + Constant.SUB_ALARM_TYPE_WATER);
//        water.setCount(AppData.globalNoticeCount.getWater());

        MsgCategoryItem emergency = new MsgCategoryItem(getContext());
        emergency.setUp(R.string.category_emergency, R.drawable.icon_emergency, Constant.NOTICE_LIST + "?type=" + Constant.MODEL_ALARM + "&subType=" + Constant.SUB_ALARM_TYPE_URGENT);
//        emergency.setCount(AppData.globalNoticeCount.getButton());

        MsgCategoryItem ignore = new MsgCategoryItem(getContext());
        ignore.setUpIgnore();

        fblContainer.addView(camera);
        fblContainer.addView(smoke);
        fblContainer.addView(gas);
        fblContainer.addView(water);
        fblContainer.addView(emergency);
        fblContainer.addView(ignore);

        AppData.addNoticeCountChangeCallback("msgFragment", () -> {
            camera.setCount(AppData.globalNoticeCount.getMonitor());
            smoke.setCount(AppData.globalNoticeCount.getGas());
            gas.setCount(AppData.globalNoticeCount.getFire());
//            water.setCount(AppData.globalNoticeCount.getWater());
//            emergency.setCount(AppData.globalNoticeCount.getButton());
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_msg;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
}